package com.acme.bankapp.domain.bank;


/**
 * @author Andrey Alekov
 *
 */
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.acme.bankapp.BankApplication;
import com.acme.bankapp.account.AbstractAccount;

/*
 * Bank client class.
 */
public class Client {
	final static Logger logger = LoggerFactory.getLogger(BankApplication.class);
	private String name;
	private Gender gender = Gender.MALE;
	protected AbstractAccount account;

	public Client(String clientName, Gender clientGender) {
		this.setGender(clientGender);
		this.setName(clientName);
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) { return true;}
		if (obj == null) { return false;}
		if (obj instanceof Client){
			final Client clientObj = (Client) obj;
			if (!this.name.equals(clientObj.getName())){ return false; }
			if (!this.gender.equals(clientObj.getGender())){ return false; }
			if (this.account != null){
				if (!this.account.equals(clientObj.getAccount())){ return false; }				
			}
			return true;
		}
		return false;
	}
	
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	
	
//	public AbstractAccount getAccounts(){
//		return this.account;
//	}
	
	public String getClientSalutation() {
		return this.gender.getGreetings();
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Gender getGender() {
		return gender;
	}
	
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	
	public AbstractAccount getAccount() {
		return account;
	}
	
	public void setAccount(AbstractAccount account) {
		this.account = account;
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Client: " + getClientSalutation() + " " + this.name;
	}
}
